package com.youlu.myapplication.scratch;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import java.util.List;

public class ScratchView extends View {
    /* access modifiers changed from: private */
    public ScratchCallBack scratchCallBack;

    public ScratchView(Context context) {
        super(context);
    }

    public ScratchView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public ScratchView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    /* access modifiers changed from: protected */
    @Override
    public void onDraw(Canvas canvas) {
        List<Path> paths = this.scratchCallBack.getPaths();
        List<Boolean> e = this.scratchCallBack.onDraw();
        if (paths.size() != 0) {
            int d = this.scratchCallBack.d();
            while (d > 0 && paths.get(d - 1) != ScratchFragment.a) {
                d--;
            }
            while (d < Math.min(this.scratchCallBack.d(), paths.size())) {
                if (d >= e.size() || e.get(d).booleanValue()) {
                    canvas.drawPath(paths.get(d), this.scratchCallBack.setScratchViewCallBack());
                }
                d++;
            }
        }
        if (this.scratchCallBack.path() != null) {
            canvas.drawPath(this.scratchCallBack.path(), this.scratchCallBack.setScratchViewCallBack());
        }
    }

    public static abstract class ScratchCallBack {
        public abstract Paint setScratchViewCallBack();

        public abstract List<Path> getPaths();

        public abstract Path path();

        public abstract int d();

        public abstract List<Boolean> onDraw();

        public void setScratchViewCallBack(ScratchView scratchView) {
            scratchView.scratchCallBack = this;
        }
    }
}